from django.db import models


# 阶段名称
class Stage(models.Model):
    title = models.CharField('阶段名', max_length=100, null=True)
    name = models.CharField('阶段标题', max_length=100, null=False)
    seq_num = models.IntegerField('序号', default=1, null=False)

    class Meta:
        db_table = 'syl_stage'
        verbose_name = '课程阶段'
        verbose_name_plural = verbose_name
        ordering = ['seq_num']

    def __str__(self):
        return self.name


# 路径表
class Path(models.Model):
    name = models.CharField(max_length=50, verbose_name='路径名称')
    pic = models.ImageField(upload_to='pic/%Y%m%d', blank=True, max_length=512)
    desc = models.TextField(verbose_name='路径相关描述')
    stages = models.ManyToManyField(Stage, db_table='syl_rel_pathstages', verbose_name='拥有阶段')
    study_num = models.IntegerField(verbose_name='学生人数', default=0)
    course_num = models.IntegerField(verbose_name='课程数量', default=0)
    study_time = models.IntegerField(verbose_name='预计学习时间', default=0)
    add_sum = models.IntegerField(verbose_name='加入路径人数', default=0)

    class Meta:
        db_table = 'syl_path'
        verbose_name = '路径'
        verbose_name_plural = verbose_name
        ordering = ['-study_num']

    def __str__(self):
        return self.name

# Create your models here.
